package com.sxu.demo.reentrantlock;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 条件变量基础用法
 */
public class Test4 {
    private static ReentrantLock lock = new ReentrantLock();

    public static void main(String[] args) throws InterruptedException {
        // 创建条件变量
        Condition condition1 = lock.newCondition();
        Condition condition2 = lock.newCondition();

        lock.lock();
        // 当前线程释放锁进入等待
        condition1.await();

        // 唤醒一个在该条件下等待的线程
        condition1.signal();
        // 唤醒所有在该条件下等待的线程
        condition1.signalAll();
    }
}
